﻿using Size_W = System.Int64;

namespace JiShiBen.Core.DataStructure
{
	public class Span : DoublyLinkedList<Span>.DoublyLinkedListNode
	{
		public Span(SpanTable table, int bufferId, Size_W offset, Size_W length)
			: base(table)
		{
			Buffer = bufferId;
			Offset = offset;
			Length = length;
		}

		public override Span Previous { get; set; }

		public override Span Next { get; set; }

		public int Buffer { get; private set; }

		public Size_W Offset { get; set; }

		public Size_W Length { get; set; }

		public Size_W LastIndex
		{
			get { return Offset + Length; }
		}

		protected override void Dispose(bool disposing)
		{
			if (!disposing) return;

			Previous = null;
			Next = null;
		}

		public override Span CastToChildType()
		{
			return this;
		}
	}
}
